package com.snda.lib.task;

import java.util.HashMap;
import java.util.Map;
import com.snda.lib.http.HttpUtil;
import com.snda.lib.http.ICallBack;
import android.content.Context;

// 所有Http Post请求的基类
public class HttpUploadFileTask extends HttpAnsycTask {

	protected String strFilePath; // 需要上传的文件的路径

	public HttpUploadFileTask(Context context, ICallBack callback) {
		super(context, callback);
	}

	public void setUploadFile(String strPath) {
		strFilePath = strPath;
	}

	@Override
	protected Map<String, Object> doHttpRequest() {

		Map<String, Object> map = new HashMap<String, Object>();
		map = httpRequest.doFilePostRequest(strUrl, strFilePath);
		return map;
	}

	protected Map<String, Object> parseResponse(String strResponse) {
		return null;
	}

	protected Map<String, Object> process(Map<String, Object> map) {

		Map<String, Object> mapData = checkResponse(map);
		Integer nError = (Integer) map.get(HttpUtil.KEY_ERROR_CODE);
		if (nError != HttpUtil.ERROR_SUCCESS)
			return mapData;

		String strResponse = (String) map.get(HttpUtil.KEY_CONTENT);
		return parseResponse(strResponse);
	}

}